import tkinter as tk
from tkinter import ttk
import random
from time import sleep
from threading import Thread
from concurrent.futures import ThreadPoolExecutor





class App(tk.Tk):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        label = ttk.Label(self, text="Hello world")
        label.pack()
        button = ttk.Button(self, text='开始', command=self.run)
        button.pack()


    def run(self):
        threads = []
        for i in range(300):
            t = Thread(target=self._show_warm_tip)
            threads.append(t)
            sleep(0.01)
            threads[i].start()

    def _show_warm_tip(self):
        window = tk.Tk()
        screen_width = window.winfo_screenwidth()
        screen_height = window.winfo_screenheight()
        window_width = 250
        window_height = 60
        x = random.randrange(0, screen_width - window_width)
        y = random.randrange(0, screen_height - window_height)
        window.title('温馨提示')
        window.geometry(f"{window_width}x{window_height}+{x}+{y}")
        tips = [
            '多喝水哦~', '保持微笑呀', '每天都要元气满满',
            '记得吃水果', '保持好心情', '好好爱自己', '我想你了',
            '梦想成真', '期待下一次见面', '金榜题名',
            '顺顺利利', '早点休息', '愿所有烦恼都消失',
            '别熬夜', '今天过得开心嘛', '天冷了，多穿衣服'
        ]
        tip = random.choice(tips)
        bg_colors = [
            'lightpink', 'skyblue', 'lightgreen', 'lavender',
            'lightyellow', 'plum', 'coral', 'bisque', 'aquamarine',
            'mistyrose', 'honeydew', 'lavenderblush', 'oldlace'
        ]
        bg = random.choice(bg_colors)
        tk.Label(
            window,
            text=tip,
            bg=bg,
            font=16,
            width=30,
            height=3
        ).pack()
        window.attributes('-topmost', True)
        window.mainloop()


if __name__ == '__main__':
    app = App()
    app.mainloop()
